package com.dzf.controller;

import com.dzf.entity.*;


import com.dzf.service.OrdService;

import com.dzf.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;

import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;



import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author DZF
 * 提供给远程调用的类
 */
@RestController
@RequestMapping("/api/public")
public class PublicController {
    @Autowired
    OrdService ordService;

    @Autowired
    SessionUtil sessionUtil;

    @RequestMapping("/ord/findOrdInfo")
    public RespJson findOrdInfo(@RequestBody Map<String,Object> map)
    {
        System.out.println(map);
        //计算该页从第几行开始
        Map<String,Object> resultmap =  ordService.findOrdInfo(map);
        return RespJson.pack(200,"OK",resultmap);
    }




    @RequestMapping("/ord/findOrdLines")
    public RespJson findOrdLines(@RequestBody Map<String, Object> map)
    {
        return RespJson.pack(200,"ok",ordService.findOrdLines(map));
    }

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
    }
}
